#include <stdint.h>

#include "opcode.h"

typedef struct
{
  uint32_t andmask;
  uint32_t ormask;
  opcode_info info;
} opcode;

opcode rv32i[] = 
{
    { //lui  
        0x0000007f,0x00000037,
    },
    { //auipc
        0x0000007f,0x00000017,
    },
    { //jal  
        0x0000007f,0x0000006f,
    },
    { //jalr 
        0x0000707f,0x00000067,
    },
    { //beq  
        0x0000707f,0x00000063,
    },
    { //bne  
        0x0000707f,0x00001063,
    },
    { //blt  
        0x0000707f,0x00004063,
    },
    { //bge  
        0x0000707f,0x00005063,
    },
    { //bltu 
        0x0000707f,0x00006063,
    },
    { //bgeu 
        0x0000707f,0x00007063,
    },
    { //lb   
        0x0000707f,0x00000003,
    },
    { //lh   
        0x0000707f,0x00001003,
    },
    { //lw   
        0x0000707f,0x00002003,
    },
    { //lbu  
        0x0000707f,0x00004003,
    },
    { //lhu  
        0x0000707f,0x00005003,
    },
    { //sb   
        0x0000707f,0x00000023,
    },
    { //sh   
        0x0000707f,0x00001023,
    },
    { //sw   
        0x0000707f,0x00002023,
    },
    { //addi 
        0x0000707f,0x00000013,
    },
    { //slti 
        0x0000707f,0x00002013,
    },
    { //sltiu
        0x0000707f,0x00003013,
    },
    { //xori 
        0x0000707f,0x00004013,
    },
    { //ori  
        0x0000707f,0x00006013,
    },
    { //andi 
        0x0000707f,0x00007013,
    },
    { //slli 
        0xf800707f,0x00001013,
    },
    { //srli 
        0xf800707f,0x00005013,
    },
    { //srai 
        0xf800707f,0x40005013,
    },
    { //add  
        0xfe00707f,0x00000033,
    },
    { //sub  
        0xfe00707f,0x40000033,
    },
    { //sll  
        0xfe00707f,0x00001033,
    },
    { //slt  
        0xfe00707f,0x00002033,
    },
    { //sltu 
        0xfe00707f,0x00003033,
    },
    { //xor  
        0xfe00707f,0x00004033,
    },
    { //srl  
        0xfe00707f,0x00005033,
    },
    { //sra  
        0xfe00707f,0x40005033,
    },
    { //or   
        0xfe00707f,0x00006033,
    },
    { //and  
        0xfe00707f,0x00007033,
    },
    { //fence
        0x0000707f,0x0000000F,
    },
    { //ecall
        0xFFFFFFFF,0x00000073,
    },
    { //ebreak
        0xFFFFFFFF,0x00100073,
    },

};